package com.watermark;

import android.graphics.Point;
import android.graphics.SurfaceTexture;

/**
 * 相机的接口控制类
 */

public interface ICamera {
    /**
     * open the camera
     */
    void open(int cameraId);

    void setPreviewTexture(SurfaceTexture texture);

    /**
     * set the camera config
     */
    void setConfig(Config config);

    void setOnPreviewFrameCallback(PreviewFrameCallback callback);

    void preview();

    Point getPreviewSize();

    Point getPictureSize();

    boolean takePicture(OnTakePictureResult<byte[]> result);

    void setOnCameraOpenListener(OnCameraOpenListener listener);

    /**
     * close the camera
     */
    boolean close();

    class Config {
        public float rate = 1.778f; //宽高比
        public int minPreviewWidth = 720;// 预览、视频分辨率
        public int minPictureWidth = 1080;// 拍照分辨率
    }

    interface PreviewFrameCallback {
        void onPreviewFrame(byte[] bytes, int width, int height);
    }

    interface OnTakePictureResult<T> {
        void onPictureResult(T result);
    }

    interface OnCameraOpenListener {
        void onOpened(Point previewSize);
    }
}

